﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace calendar
{
/**
 * This class is used to represent the records in an MPX file that define
 * working hours in a calendar.
 */
public class ProjectCalendarHours : ProjectCalendarDateRange
{

    private ProjectCalendarWeek m_parentCalendar;
    private Day m_day;
    

    public ProjectCalendarHours(ProjectCalendarWeek parentCalendar)
    {
        m_parentCalendar = parentCalendar;
    }   

    public ProjectCalendarWeek ParentCalendar
    {
        get { return m_parentCalendar; }
    }

    public Day Day
    {
        get { return m_day; }

        set
        {
            if (m_day != null)
            {
                m_parentCalendar.removeHoursFromDay(this);
            }

            m_day = value;

            m_parentCalendar.attachHoursToDay(this);
        }
    }

    public override string ToString()
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("[ProjectCalendarHours ");
        foreach (DateRange dr in this)
        {
            sb.Append(dr.ToString());
        }
        sb.Append("]");
        return sb.ToString();
    }

}
}
